<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<title></title>
	<style type="text/css">
		* {
			margin: 0;
			padding: 0;
		}

		div {
			width: 200px;
			height: 200px;
			background: red;
		}
	</style>
</head>

<body>
	<div></div>
	<script type="text/javascript">
		function a(e) {
			console.log(e)
		}
		document.querySelector('div').onclick = a

		//document.onclick=a
	</script>
</body>

</html>